package com.masterlu.leetcode.daily.number.simple;

/**
 * 丑数就是只包含质因数 2, 3, 5 的正整数。
 * https://leetcode-cn.com/problems/ugly-number/
 *
 * @Author：masterlu
 * @Date：2021/3/24 10:59 下午
 */
public class S263Ugly {


    public static void main(String[] args) {
        int number = 7;
        boolean ugly = isUgly(7);
        System.out.println(ugly);
    }

    /**
     * 判断number是否为丑数
     *
     * @param n
     */
    private static boolean isUgly(int n) {

        if (n < 1){
            return Boolean.FALSE;
        }

        while (n % 2 == 0){
            n = n/2;
        }
        while (n % 3 == 0){
            n = n/3;
        }
        while (n % 5 == 0){
            n = n/5;
        }

        return n == 1;

    }
}
